package com.zhhh.domain;
// Generated 2019-10-18 10:55:08 by Hibernate Tools 3.4.0.CR1

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import static javax.persistence.GenerationType.IDENTITY;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Transient;

/**
 * BRole generated by hbm2java
 */
@Entity
@Table(name = "b_role")
public class BRole implements java.io.Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private Integer id;
	private String roleCode;
	private String roleName;
	private String roleDesc;
	private String roleType;

	private Set<BMode> modes = new HashSet<BMode>();

	private Set<BRoleModeOper> roleOpers = new HashSet<BRoleModeOper>();

	private Set<BRoleModeEm> roleEms = new HashSet<BRoleModeEm>();

	private List<RolePowerTree> childList = new ArrayList<RolePowerTree>();

	private Set<BUser> users = new HashSet<BUser>();

	public BRole() {
	}

	public BRole(String roleCode, String roleName, String roleDesc, String roleType) {
		this.roleCode = roleCode;
		this.roleName = roleName;
		this.roleDesc = roleDesc;
		this.roleType = roleType;
	}

	@Id
	@GeneratedValue(strategy = IDENTITY)

	@Column(name = "id", unique = true, nullable = false)
	public Integer getId() {
		return this.id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	@Column(name = "role_code", length = 40)
	public String getRoleCode() {
		return this.roleCode;
	}

	public void setRoleCode(String roleCode) {
		this.roleCode = roleCode;
	}

	@Column(name = "role_name", length = 40)
	public String getRoleName() {
		return this.roleName;
	}

	public void setRoleName(String roleName) {
		this.roleName = roleName;
	}

	@Column(name = "role_desc", length = 40)
	public String getRoleDesc() {
		return this.roleDesc;
	}

	public void setRoleDesc(String roleDesc) {
		this.roleDesc = roleDesc;
	}

	@Column(name = "role_type")
	public String getRoleType() {
		return this.roleType;
	}

	public void setRoleType(String roleType) {
		this.roleType = roleType;
	}

	@ManyToMany
	@org.hibernate.annotations.ForeignKey(name = "none")
	@JoinTable(name = "b_role_mode", inverseJoinColumns = @JoinColumn(name = "mode_id"), joinColumns = @JoinColumn(name = "role_id"))
	public Set<BMode> getModes() {
		return modes;
	}

	public void setModes(Set<BMode> modes) {
		this.modes = modes;
	}

	@Transient
	public List<RolePowerTree> getChildList() {
		return childList;
	}

	public void setChildList(List<RolePowerTree> childList) {
		this.childList = childList;
	}

	@OneToMany
	/**
	 * name 指关联表字段名称 referencedColumnName 指本表字段名称
	 */
	@org.hibernate.annotations.ForeignKey(name = "none")
	@JoinColumn(name = "role_code", referencedColumnName = "role_code")
	public Set<BRoleModeOper> getRoleOpers() {
		return roleOpers;
	}

	public void setRoleOpers(Set<BRoleModeOper> roleOpers) {
		this.roleOpers = roleOpers;
	}

	@OneToMany
	/**
	 * name 指关联表字段名称 referencedColumnName 指本表字段名称
	 */
	@org.hibernate.annotations.ForeignKey(name = "none")
	@JoinColumn(name = "role_code", referencedColumnName = "role_code")
	public Set<BRoleModeEm> getRoleEms() {
		return roleEms;
	}

	public void setRoleEms(Set<BRoleModeEm> roleEms) {
		this.roleEms = roleEms;
	}

	// 关联用户
	@ManyToMany(cascade = CascadeType.REFRESH, mappedBy = "roles", fetch = FetchType.LAZY)
	public Set<BUser> getUsers() {
		return users;
	}

	public void setUsers(Set<BUser> users) {
		this.users = users;
	}

}
